﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LibraryUtility.Common
{
    /// <summary>
    /// ClassName:JsScript
    /// Auther:Leo.wl
    /// Time:2010-04-14
    /// </summary>
    static public  class JsScript
    {
        /// <summary>
        /// Alerts the specified page.
        /// </summary>
        /// <param name="page">The page.</param>
        /// <param name="msg">The MSG.</param>
        public static void alert(System.Web.UI.Page page, string msg)
        {
            page.ClientScript.RegisterStartupScript(page.GetType(), "alert", "<script type=\"text/javascript\">alert('" + msg + "');</script>");
        }

        /// <summary>
        /// Ajax启动脚本 For 引用AJAX组件的页
        /// JS语句
        /// </summary>
        /// <param name="page">一般是this</param>
        /// <param name="js">如alert('test');</param>
        public static void AjaxRunJs(System.Web.UI.Page page, string js)
        {
            page.ClientScript.RegisterStartupScript(page.GetType(), "ajaxjs", string.Format("{0}", js), true);
        }
        /// <summary>
        /// Ajax启动脚本 For 引用AJAX组件的页
        /// AjaxAlert:弹出对话框
        /// </summary>
        /// <param name="page">一般是this</param>
        /// <param name="msg">对话框提示串</param>
        public static void AjaxAlert(System.Web.UI.Page page, string msg)
        {
            page.ClientScript.RegisterStartupScript(page.GetType(), "ajaxjs", string.Format("alert('{0}')", msg), true);
        }
        /// <summary>
        /// Ajax启动脚本 For 引用AJAX组件的页
        /// JS语句
        /// </summary>
        /// <param name="page">一般是this</param>
        /// <param name="js">如alert('test');</param>
        public static void AjaxEndRunJs(System.Web.UI.Page page, string js)
        {
            page.ClientScript.RegisterClientScriptBlock(page.GetType(), "ajaxjs", string.Format("{0}", js), true);
        }
    }
}
